import Vue from 'vue'
import Vuex from 'vuex'
// 导入catagtory、newlist模块
import catagtory from './catagtory'
import newlist from './newlist'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {},
    mutations: {},
    actions: {},
    // modules与state、mutations、actions是同一级别.
    modules: {
        // 将导入的模块定义在modules对象中
        catagtory,
        newlist
    },
    // 使用getters来建立子模块的快捷访问
    getters: {
        // catagtory.js中catagtory属性的快捷访问
        catagtory: state => state.catagtory.catagtory,
        // catagtory.js中currentCatagtory属性的快捷访问
        currentCatagtory: state => state.catagtory.currentCatagtory,
        // 获取当前分类id的状态
        currentList: state => state.newlist.allData[state.catagtory.currentCatagtory]
    }
})